package com.net.xpay.core.utils;

import com.google.common.base.Strings;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class UrlUtil {
    /**
     * 判断字符串是否为URL
     * @param url 需要判断的String类型url
     * @return true:是URL；false:不是URL
     */
    public static boolean isHttpUrl(String url) {
        if (Strings.isNullOrEmpty(url)) {
            return false;
        }
        boolean isurl;
        String regex ="^(https?:\\/\\/)[^\\s]*$";


        //对比
        Pattern pat = Pattern.compile(regex);
        Matcher mat = pat.matcher(url);
        //判断是否匹配
        isurl = mat.matches();

        return isurl;
    }
}
